<script type="text/javascript">
var uploader = WebUploader.create({
        swf: '/admin/lib/webuploader/0.1.5/Uploader.swf',
		server: 'http://123.56.14.98:8080/guidance_service/front/info/input.do',  // 文件接收服务端。
        auto : true,
        pick : "#input",
        resize : false,
        chunked: true
});

var loadingIndex;
uploader.on("uploadProgress",function(){
	loadingIndex = layer.load(1, {shade: [0.5,'#fff'] });//0.1透明度的白色背景
}).on("uploadComplete",function(){
	layer.close(loadingIndex); 
});
uploader.on( 'uploadSuccess', function( file,response) {
	if(response.resultCode == 200){
		layer.msg(response.message,{icon:1,time:3000},function(){
			location.replace(location.href);
		});
	}else if(response.resultCode  == 400){
		layer.open({  //页面层
		  type: 1,
		  title:"等待确认：",
		  skin: 'layui-layer-rim', //加上边框
		  area: ['420px', '420px'], //宽高
		  content: response.data.toString().replace(new RegExp(/(是否导入,)/g),"是否导入<br/>"),
		  btn: ['确认导入', '取消导入'],
		  yes: function(index, layero){ //按钮【按钮一】的回调
		  	   $.post("http://localhost:8080/guidance_service/front/info/confirm.do",{"UUID":response.ext},function(reslut){
		  	   		layer.msg(reslut.message,{icon:2,time:3000},function(){
						location.replace(location.href);
					});
		  	   });
		   	   layer.close(index); //如果设定了yes回调，需进行手工关闭
		  }
		});
	}else{
		layer.msg(response.message,{icon:2,time:3000},function(){
			location.replace(location.href);
		});
	}
	
});
uploader.on( 'uploadError', function( file ) {  //上传失败
	layer.msg('导入失败',{icon:2,time:1000},function(){
			location.replace(location.href);
	});
});
</script> 
